<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
		div {width: 100px; height: 100px;background-color: red; position: absolute;}
	</style>
	<script src="jquery-1.10.1.min.js"></script>
	<script type="text/javascript">
	$(function(){
		var disX = 0;
		var disY = 0;

		$('div').mousedown(function(ev){
			disX = ev.pageX - $(this).offset().left;
			disY = ev.pageY - $(this).offset().top;

			$(document).mousemove(function(ev){
				$('div').css('left', ev.pageX - disX);			//pageX是没有括号的
				$('div').css('top', ev.pageY - disY);
			})	

			$(document).mouseup(function(){
				$(document).off();
			})

			return false;
		})
	})
	</script>
</head>
<body>aaa
	<div></div>
</body>
</html>